import 'elix/define/Dialog.js'
import ykHtml from './yczs.html'
const $click = (element, handler) => {
    element.addEventListener('click', handler)
    element.addEventListener('touchend', handler)
  }
export class yczs extends HTMLElement{
    constructor(svgShow){
        super()
        const template = document.createElement('template')
        template.innerHTML = ykHtml
        this.svgShow = svgShow
        this.svgShow.$svgShow.append(template.content.cloneNode(true))
        this.$docDialog = this.svgShow.$svgShow.querySelector("#yczs_box")
        this.$container = this.svgShow.$svgShow.querySelector("#container4")
        this.$txtVal = this.svgShow.$svgShow.querySelector("#setV")
        this.init()
    }

    open(obj,needsave){
        this.obj = obj
        this.needsave = needsave
        this.$docDialog.open()
    }

    init(){
        this.$close = this.svgShow.$svgShow.querySelector('.closeZS')
        var that = this
        $click(this.$close, function () {
            that.$docDialog.close()
        })
        this.$closebtn = this.svgShow.$svgShow.querySelector('#qx')
        this.$cfmbtn = this.svgShow.$svgShow.querySelector('#qd')
        $click(this.$closebtn, function () {
            that.$docDialog.close()
        })
        $click(this.$cfmbtn, function () {
            that.obj.setValue(that.$txtVal.value,that.needsave)
            that.$docDialog.close()
        })
    }

}
customElements.define('yczs-dialog', yczs)

